package com.homework;

import java.util.Scanner;

public class demo06 {
    public static void main(String[] args) {
        //静态初始化数组
        int[] arr = new int[]{1, 2, 3, 4, 5, 5, 65, 5};
        //创建扫描器
        Scanner sc = new Scanner(System.in);
        //键盘录入数据
        System.out.println("请输入一个数字");
        int num = sc.nextInt();
        int tp = 0;
        //遍历数组并查找
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == num) {
                tp = i + 1;
            }
        }
        System.out.println(num + "在数组中最后一次出现的位置为：" + tp);
    }
}
